/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFPIDManager
  \brief to manage particle identification (PID) objects in ETFAna
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2021-12-13
  \date 2021-12-13 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-12-13   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#include "ETFPIDManager.h"
#include "ETFMsg.h"
#include "ETFPID.h"
#include "ETFPIDm.h"

ETFPIDManager *ETFPIDManager::fInstance = nullptr;

ETFPIDManager::ETFPIDManager(){
  fPID = new ETFPID();
  fPIDm = new ETFPIDm();
} // end ctor

ETFPIDManager *ETFPIDManager::Instance(){
  if(!fInstance) fInstance = new ETFPIDManager();
  return fInstance;
} // end member function fInstance

ETFPIDManager::~ETFPIDManager(){
  if(fPID) delete fPID;
  if(fPIDm) delete fPIDm;
} // end dtor

void ETFPIDManager::Register(){
  if(GetPID()) fPID->Register();
  if(GetPIDm()) fPIDm->Register();
} // end member function Register

ETFPID *ETFPIDManager::GetPID() const{
  return fPID;
} // end member function GetPID

ETFPIDm *ETFPIDManager::GetPIDm() const{
  return fPIDm;
} // end member function GetPIDm

void ETFPIDManager::SetMagneticIntensity(double b){
  fPID->SetMagneticIntensity(b);
  fPIDm->SetMagneticIntensity(b);
} // end member function SetMagneticIntensity

void ETFPIDManager::Draw(){
  if(fPID) fPID->Draw();
  if(fPIDm) fPIDm->Draw();
} // end member function Draw
